package com.saydc.forms.busquedas;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class AltaBusquedaForm extends ActionForm {

	private static final long serialVersionUID = 1L;
	private int puestoEspecifico;
	private int expertise;
	private String cantBuscada;
	
	
	public int getPuestoEspecifico() {
		return puestoEspecifico;
	}
	public void setPuestoEspecifico(int puestoEspecifico) {
		this.puestoEspecifico = puestoEspecifico;
	}
	public String getCantBuscada() {
		return cantBuscada;
	}
	public void setCantBuscada(String cantBuscada) {
		this.cantBuscada = cantBuscada;
	}
	public int getExpertise() {
		return expertise;
	}
	public void setExpertise(int expertise) {
		this.expertise = expertise;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,	HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		if(puestoEspecifico == -1){
			errors.add("puestoRequired", new ActionMessage("error.busquedas.puestoRequired"));
		}
		if(expertise == -1){
			errors.add("expertiseRequired", new ActionMessage("error.busquedas.expertiseRequired"));
		}
		if(cantBuscada.equals("") || cantBuscada.equals("0") || cantBuscada.equals("00")){
			errors.add("cantBuscadaInvalida", new ActionMessage("error.busquedas.cantidadInvalida"));
		}
		return errors;
	}

}
